package org.emergency.framework.interceptor;

import org.apache.log4j.Logger;

import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.AbstractInterceptor;

/**
 * @author Zheng
 * 
 */
public class AuthorityInterceptor extends AbstractInterceptor {

	private static final long serialVersionUID = 4635556971193244669L;

	private static Logger LOG = Logger.getLogger(AuthorityInterceptor.class);

	@Override
	public String intercept(ActionInvocation invocation) throws Exception {
//		// 取得请求的Action名
//		String actionClass = invocation.getInvocationContext().getName();
//		// 执行方法名称
//		String actionMethod = invocation.getProxy().getMethod().trim();
//		// 获取到namespace，还能够获取到要执行的方法，class等
//		String nameSpace = invocation.getProxy().getNamespace();
//		String actionUrl = nameSpace + actionClass + "!" + actionMethod
//				+ ".action";
//
//		LOG.debug("action: [" + actionUrl + " ]");
//
//		if (actionMethod.equals("login") || actionMethod.equals("logout")) {
//			return invocation.invoke();
//		} else {
//			ActionContext ac = invocation.getInvocationContext();
//			TbUser user = Context.getCurrentUser();
//
//			if (user == null) {
//				return Action.LOGIN;
//			}
//			if(Context.hasPrivilege(actionUrl)){
//				return invocation.invoke();
//			}
//		}
//		return "noPermit";
		return null;
	}

}
